package com.go.core.repo;

import com.go.core.bean.RunningScore;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface RunningScoreRepo extends JpaRepository<RunningScore, Integer> {

    @Transactional
    @Modifying
    @Query("update RunningScore sb set sb.score = ?2 where sb.uuid = ?1")
    int updateScoreByUUID(String uuid, int socre);

    @Query(nativeQuery = true, value = "select * from small_run_score")
    List<RunningScore> getScoreBorad();

    @Query(value = "select sb from RunningScore sb where sb.uuid = ?1")
    RunningScore findByUUID(String uuid);
}
